package com.c.yinyuezhushou.MRetrofit;

import android.content.Context;

import com.c.yinyuezhushou.Interface.MyInterface;
import com.c.yinyuezhushou.MyApplication;
import com.c.yinyuezhushou.R;

import java.util.List;
import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import tech.nicesky.retrofit2_adapter_rxjava3.RxJava3CallAdapterFactory;

public  class MyRetrofit {

    public static <T> T getOb(Context context,Class<T> c){

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(context.getString(R.string.music_url))
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava3CallAdapterFactory.create())
                .build();
        return retrofit.create(c);
    }


    public static <T> T Down(Context context,Class<T> c){
        MyApplication myApplication =(MyApplication) context.getApplicationContext();

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(context.getString(R.string.music_url))
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava3CallAdapterFactory.create())
                .client(myApplication.getOkHttpClient())
                .build();
        return retrofit.create(c);
    }

    public static <T> T getCk(Context context,Class<T> c){

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(context.getString(R.string.cookie_url))
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        return retrofit.create(c);
    }
}
